#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

int gcd(int x,int y){return !y ? x : gcd(y,x%y);}

const int N = 710;
int a[N],n;
bool clink[N][N],f[N][N][2];

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in;
	for(int i = 1;i <= n;i++) a[i] = in;
	for(int i = 1;i <= n;i++)
		for(int j = 1;j <= n;j++)
			clink[i][j] = clink[j][i] = (gcd(a[i],a[j]) != 1);
	for(int i = 1;i <= n;i++) f[i][i][0] = f[i][i][1] = 1;
	for(int len = 1;len <= n;len++){
		for(int l = 1,r = len;r <= n;l++,r++){
			for(int k = l;k <= r;k++)
				if(f[l][k][1] && f[k][r][0]){
					if(l == 1 && r == n) return puts("YES"),0;
					if(clink[k][r+1]) f[l][r+1][1] = 1;
					if(clink[k][l-1]) f[l-1][r][0] = 1;
				}
		}
	}puts("NO");
	return 0;
}

